package com.my.sys.controller;

import com.my.app.http.PageResult;
import com.my.sys.model.SysResource;
import com.my.sys.service.SysResourceService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by 80002023 on 2016/6/7.
 */
@RestController
@RequestMapping("sys/resource")
public class SysResourceController {

    private final Logger logger = LogManager.getLogger(getClass());

    @Autowired
    private SysResourceService sysResourceService;

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView indexView() {

        return new ModelAndView("index");
    }

    @RequestMapping(method = RequestMethod.POST)
    public PageResult<SysResource> pageData(@RequestBody PageResult<SysResource> result) {
        logger.info("query resource data");
        result = sysResourceService.findPage(null, result.pageNum, result.pageSize);
        result.status = 1;
        return result;
    }
}
